import request from '@/utils/request';

export function login(data) {
    return request({
        url: '/sysUser/login',
        method: 'post',
        data
    });
}

export function getInfo(token) {
    return new Promise((resolve, reject) => {
        console.warn('开始网络请求');
        resolve({
            data: {
                roles: ['admin']
                // introduction: 'I am a super administrator',
                // avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
                // name: 'Super Admin'
            }
        });
    });
}

export function logout() {
    return new Promise((res) => {
        res({});
    });
}

/// 分页查询用户信息列表
export function userlist(data) {
    return request({
        url: '/sysUser/querySysUser',
        method: 'post',
        data
    });
}


//不分页查询
export function findSysUser(data) {
    return request({
        url: '/sysUser/findSysUser',
        method: 'post',
        data
    });
}

//项目列表查询【不分页】
export function queryProjects(data) {
    return request({
        url: '/projectBaseInfo/queryProjects',
        method: 'post',
        data
    });
}

//保存用户信息
export function saveSysUser(data) {
    return request({
        url: '/sysUser/saveSysUser',
        method: 'post',
        data
    });
}

//删除用户信息
export function deleteSysUser(data) {
    let userId = data['id'];
    return request({
        url: `/sysUser/${userId}/deleteSysUser`,
        method: 'post',
        data
    });
}

//删除用户信息
export function modifySysUser(data) {
    let userId = data['id'];
    return request({
        url: `/sysUser/${userId}/modifySysUser`,
        method: 'post',
        data
    });
}

/// 用户详情
export function getById(userId) {
    return request({
        url: `/sysUser/${userId}/getById`,
        method: 'get'
    });
}








// ########################################################################################
// 【权限】
// ########################################################################################


/// 权限列表不分页
export function findSysPermission(data) {
    return request({
        url: '/sysPermission/findSysPermission',
        method: 'post',
        data
    });
}

/// 权限列表
export function querySysPermission(data) {
    return request({
        url: '/sysPermission/querySysPermission',
        method: 'post',
        data
    });
}

/// 添加权限
export function saveSysPermission(data) {
    return request({
        url: '/sysPermission/saveSysPermission',
        method: 'post',
        data
    });
}

/// 删除权限
export function deletePermission(id) {
    return request({
        url: `/sysPermission/${id}/deletePermission`,
        method: 'post'
    });
}

/// 修改权限
export function modifySysPermission(data) {
    let permissionId = data['id'];
    return request({
        url: `/sysPermission/${permissionId}/modifySysPermission`,
        method: 'post',
        data
    });
}



// ########################################################################################
// 【菜单】
// ########################################################################################

/// 菜单列表
export function findSysMenu(data) {
    return request({
        url: '/sysMenu/findSysMenu',
        method: 'post',
        data
    });
}

/// 添加菜单
export function saveSysMenu(data) {
    return request({
        url: '/sysMenu/saveSysMenu',
        method: 'post',
        data
    });
}

/// 删除菜单
export function deleteSysMenu(menuId) {
    return request({
        url: `/sysMenu/${menuId}/deleteSysMenu`,
        method: 'post'
    });
}

/// 修改菜单
export function modifySysMenu(data) {
    let menuId = data['menuId'];
    return request({
        url: `/sysMenu/${menuId}/modifySysMenu`,
        method: 'post',
        data
    });
}
